package com.mycompany.myapp.web.rest.electricbicyclecontroller;

import com.codahale.metrics.annotation.Timed;
import com.mycompany.myapp.domain.Stewarder;
import com.mycompany.myapp.service.StewarderService;
import com.mycompany.myapp.service.StewarderServiceInterface;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * Create by wys on 2018/7/25
 */
@RestController
@RequestMapping("/api")
@Api(tags = "维护员相关API")
public class StewardController {

    @Autowired
    StewarderService stewarderService;

    @GetMapping("/getAllSteward")
    @ApiOperation(value = "获得全部的维护员",notes = "获得全部的维护员")
    @Timed
    public List<Stewarder> getAllSteward() {

        return stewarderService.getAllSteward();
    }

    @GetMapping("/getAllFreeSteward")
    @ApiOperation(value = "获取空闲的维护员",notes = "获取空闲的维护员")
    @Timed
    public List<Stewarder> getAllFreeSteward() {

        return stewarderService.getAllFreeSteward();
    }

    @PostMapping("/maintenanceBicycleSituation")
    @Timed
    public ResponseEntity<String> maintenanceBicycleSituation(@RequestParam String bicycleID,@RequestParam String stewarderID,@RequestParam String stewardState) {

        String result = stewarderService.maintenanceBicycleSituation(bicycleID, stewarderID, stewardState);

        return ResponseEntity.ok()
            .body(result);

    }

    @PostMapping("/getStewarderForElecBicycle")
    @Timed
    public ResponseEntity<String> getStewarderForElecBicycle(String  stewarderID) {

        String result = stewarderService.getStewarderForElecBicycle(stewarderID);

        return ResponseEntity.ok()
            .body(result);
    }

}
